home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / apb17.zip / SOUND.INC < prev    next >
Text File  |  1990-12-20  |  940b  |  38 lines

  1.  
  2.     ' Sound statement include program. Use:
  3.     ' $include "Sound.inc"
  4.     ' to include the normal basica SOUND statement 
  5.  
  6.     ' Return the current value of the timer counter in bios
  7. Def TimerVal%()
  8.     Def Seg=&h40
  9.     TimerVal%=Peek(&h6c)+(Peek(&h6d) shl 8)
  10. End Def
  11.  
  12.     ' Do a sound for a specified length of time
  13.     ' Enter:
  14.     '    Freq! is the frequency
  15.     '    Dur is the duration in clock ticks
  16. sub sound freq!,dur%
  17. Static SndInit%
  18. Local Tone%
  19.     If SndInit%=0 then    ' First time through
  20.         Out &h43,&hb6
  21.         SndInit%=1    ' Reset flag
  22.     End If
  23.     If (Freq!<40) then Freq!=40    ' Lowest tone possible
  24.         ' Compute Tone% value from frequency
  25.     Tone%=(1193182/Freq!)
  26.         ' Now set the tone
  27.     Out &h42,Tone% and &hff    ' Low byte
  28.     Out &h42,Tone% shr 8    ' high byte
  29.         ' Turn tone on
  30.     Out &h61,Inp(&h61) or 3
  31.         ' Wait for duration
  32.     DesiredVal%=TimerVal%()+Dur%
  33.     While DesiredVal%>TimerVal%()
  34.     Wend
  35.         ' Turn tone off
  36.     Out &h61,Inp(&h61) and &hfc
  37. End Sub
  38.